home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / HIERARCH.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  3.6 KB  |  114 lines

  1. /*
  2.  * $Id: hierarchy_test.java,v 1.11 1996/10/03 19:46:51 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.test;
  7.  
  8. import sub_arctic.lib.*;
  9. import sub_arctic.output.*;
  10. import sub_arctic.input.*;
  11. import sub_arctic.constraints.std_function;
  12.  
  13. import java.awt.Font;
  14.  
  15. public class hierarchy_test extends interactor_applet  {
  16.   static String[] car_data= { "Cars", "Porsche", "Mercedes" , "Ferrari", 
  17.                   "Volvo","Saab", "Lexus", "Infinity" , 
  18.                   "Jaguar", "Rolls Royce", "Audi"};
  19.   static String[] mercedes={"300CE", "560SEL", "520SL", "420SEL", "340C"};
  20.   static String[] porche={"911", "911 carrera", "944", "928s", "959", "911"};
  21.   static String[] rolls={"Left Hand Drive", "Right Hand Drive"};
  22.   static String[] convert={"Hard top", "Convertible"};
  23.   public void build_ui(base_parent_interactor top) {
  24.     int i,j;
  25.     String s;
  26.     interactor item,tmp;
  27.     Font font=new Font("Helvetica",Font.BOLD, 16);
  28.     int object_width=150;
  29.     panner p;
  30.  
  31.     /* make a manager */
  32.     hierarchy_parent mgr=new hierarchy_parent(0,0);
  33.     mgr.open();
  34.  
  35.       /* setup the panner */
  36.     p=new panner(mgr);
  37.     /* want to force the scrollbars? */
  38.     /* p.set_force_scrollbars(true); */
  39.     p.set_w_constraint(std_function.offset(PARENT.X2(), 0));
  40.     p.set_h_constraint(std_function.offset(PARENT.Y2(),0));
  41.  
  42.     /* put the panner in the toplevel */
  43.     top.add_child(p);
  44.     for (i=0; i<car_data.length; ++i) {
  45.       s=car_data[i];
  46.       if (s.equals("Porsche")) {
  47.     /* make a submanager */
  48.     item=new hierarchy_parent(0,0);
  49.     ((hierarchy_parent)item).
  50.       set_special_child(new label(s,object_width, font));
  51.     for (j=0; j<porche.length; ++j) {
  52.       item.add_child(new label(porche[j],object_width, font));
  53.     }
  54.       } else {
  55.     /* make submanager */
  56.     if (s.equals("Mercedes")) {
  57.       item=new hierarchy_parent(0,0);
  58.       ((hierarchy_parent)item).
  59.         set_special_child(new label(s,object_width, font));
  60.       for (j=0; j<mercedes.length; ++j) {
  61.         /* final level of indentation! hard top or convertible? */
  62.         if (mercedes[j].equals("520SL")) {
  63.           tmp=new hierarchy_parent(0,0);
  64.           ((hierarchy_parent)tmp).
  65.         set_special_child(new label(mercedes[j],
  66.                         object_width,font));
  67.           tmp.add_child(new label(convert[0],object_width,font));
  68.           tmp.add_child(new label(convert[1],object_width,font));
  69.           item.add_child(tmp);
  70.         } else {
  71.           item.add_child(new label(mercedes[j],object_width, font));
  72.         }
  73.       }
  74.     } else {
  75.       /* possible rolls */
  76.       if (s.equals("Rolls Royce")) {
  77.         item=new hierarchy_parent(0,0);
  78.         ((hierarchy_parent)item).
  79.           set_special_child(new label(s, object_width,font));
  80.         for (j=0; j<rolls.length; ++j) {
  81.           item.add_child(new label(rolls[j],object_width,font));
  82.         }
  83.       } else {
  84.         /* base case.. no submenu ... but might be first*/
  85.         item=new label(s,object_width, font);
  86.       }
  87.     }
  88.       }
  89.       /* might be first child */
  90.       if (s.equals("Cars")) {
  91.     mgr.set_special_child(item);
  92.       } else {
  93.     mgr.add_child(item);
  94.       }
  95.     }
  96.   }
  97. }
  98. /*=========================== COPYRIGHT NOTICE ===========================
  99.  
  100. This file is part of the subArctic user interface toolkit.
  101.  
  102. Copyright (c) 1996 Scott Hudson and Ian Smith
  103. All rights reserved.
  104.  
  105. The subArctic system is freely available for most uses under the terms
  106. and conditions described in 
  107.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  108. and appearing in full in the lib/interactor.java source file.
  109.  
  110. The current release and additional information about this software can be 
  111. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  112.  
  113. ========================================================================*/
  114.